package com.maduar.mybatis.demo;

import lombok.Getter;

import java.util.Objects;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @date 2021-04-15 23:00
 */
@Getter
public enum OpratorEnum {

    /**
     * @Author: danny.pang
     * @Date: 2021-04-15 23:1
     * @Discription: add
     */
    ADD(1, "add"),
    /**
     *  @Author: danny.pang
     *  @Date: 2021-04-15 23:1
     *  @Discription:   sub
     *
     */
    SUB(2, "sub"),
    ;

    private Integer code;
    private String desc;

    OpratorEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static OpratorEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }

        for (OpratorEnum o : OpratorEnum.values()) {
            if (o.getCode().equals(code)) {
                return o;
            }
        }

        return null;
    }
}
